package com.example.demo.controller;

import com.example.demo.controller.data.ReturnData;
import com.example.demo.entity.CircleLike;
import com.example.demo.entity.Comment;
import com.example.demo.sevice.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 评论相关的接口控制类
 *
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Resource
    CommentService commentService;
    /**
     * 给圈子评论的接口
     * @param comment
     * @param request
     * @return
     */
    @PostMapping("/add")
    public ReturnData add(@RequestBody Comment comment, HttpServletRequest request) {
        String token = request.getHeader("token");
        return  commentService.add(comment,token);
    }

    /**
     * 获取某条圈子的评论列表
     * @param circleId
     * @return
     */
    @GetMapping("/getCommentList")
    public ReturnData getCommentList(int circleId) {
        return  commentService.getCommentList(circleId);
    }


    /**
     * 删除评论
     * @param comment
     * @param request
     * @return
     */
    @PostMapping("/delete")
    public ReturnData delete(@RequestBody Comment comment, HttpServletRequest request) {
        String token = request.getHeader("token");
        return  commentService.delete(comment,token);
    }
}
